﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2022 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

namespace Abc.Application;

public interface IDataConfigService
{
    /// <summary>
    /// 新增或更新一条
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    Task InsertOrUpdate(DataConfigInput input);

    /// <summary>
    /// 删除一条
    /// </summary>
    /// <param name="id"></param>
    Task Delete(int id);

    /// <summary>
    /// 批量删除
    /// </summary>
    /// <param name="ids">需要删除的数据，多条以英文逗号隔开</param>
    Task BatchDelete(string ids);

    /// <summary>
    /// 查询所有
    /// </summary>
    /// <returns></returns>
    List<DataConfigOut> GetAll();

    /// <summary>
    /// 查询一条
    /// </summary>
    /// <param name="id"></param>
    Task<TEntity> Get<TEntity>(int id);

    /// <summary>
    /// 查询一条
    /// </summary>
    /// <param name="key"></param>
    Task<DataConfigOut> GetByKey(string key);

    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="searchQuery"></param>
    /// <returns></returns>
    Task<LayuiPagedList<DataConfigOut>> GetAllByPageToLayui(DataConfigQuery searchQuery);

    /// <summary>
    /// 查询下拉树
    /// </summary>
    /// <returns></returns>
    Task<Dtree> GetDtree(string pid = "");

    /// <summary>
    /// 获取系统设置
    /// </summary>
    /// <returns></returns>
    Task<TEntity> GetSetting<TEntity>(int pid) where TEntity : new();

    /// <summary>
    /// 获取系统设置
    /// </summary>
    /// <param name="pkey">父级</param>
    /// <returns></returns>
    Task<TEntity> GetSetting<TEntity>(string pkey) where TEntity : new();

    /// <summary>
    /// 新增或修改设置
    /// </summary>
    /// <param name="input">输入对象</param>
    /// <param name="pkey">父级</param>
    /// <returns></returns>
    Task AddOrUpdateSetting(object input, string pkey);

    /// <summary>
    /// 设置状态
    /// </summary>
    /// <param name="id"></param>
    /// <param name="state"></param>
    /// <param name="field">字段名</param>
    /// <returns></returns>
    Task SetState(int id, bool state, string field);

    #region 数据字典

    /// <summary>
    /// 新增或更新一条
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    Task InsertOrUpdate(DataDictionaryInput input);

    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="searchQuery"></param>
    /// <returns></returns>
    Task<LayuiPagedList<DataDictionaryOut>> GetAllByPageToLayui(DataDictionaryQuery searchQuery);

    #endregion 数据字典
}